﻿#ifndef __SS_CAMERA_H__
#define __SS_CAMERA_H__
#include "../ssComponent.h"
#include "../../opengl/vbo/ssFBO.h"
#include "../../3dMath/ssMatrix.h"
#include "../../3dMath/ssVector.h"

namespace StarSeeker
{

enum CAMERA_TYPE
{
	CAMERA_TYPE_NULL = 0,
	CAMERA_TYPE_TL,
	CAMERA_TYPE_TP
};

class ssCamera : public ssComponent
{
public:
	ssCamera(void);
	virtual ~ssCamera(void);

	const ssFLOAT4x4X& GetProjMatrix();
	const ssFLOAT4x4X& GetViewMatrix();
	const ssFLOAT4x4X& GetProjViewMatrix();
	//设置投影矩阵
	void SetProjMatrix(ssFLOAT4x4X &p);
	//判断摄像机类型
	bool IsType(CAMERA_TYPE type);
	//清除缓冲区
	void ClearBuffer();
	//激活像机
	void ActiveCamera();
	void InactiveCamera();
	//设置为主像机
	void SetMainCamera();
	//渲染到纹理
	bool Render2Texture(GLenum attachmentPoint, GLuint textureId);
	//删除渲染到纹理
	void DelRender2Texture();

	bool R2TBegin();
	void R2TEnd();
protected:
	void OnAdd();
	void ComputeProjViewMatrix();

	CAMERA_TYPE			m_cameraType;
	ssFLOAT4x4X			m_matProj;			//投影矩阵
	ssFLOAT4x4X*		m_pmatView;			//视图矩阵
	ssFLOAT4x4X			m_matProjView;		//投影x视图
public:
	static ssCamera*	s_currentCamera;	//当前摄像机指针,使用多个摄像机就用他去指向不同的相机对象做切换
	static ssCamera*	s_mainCamera;		//主摄像机指针
private:
	ssFBO				m_fbo;
};

}
#endif
